#ifndef SANGAME_BASE_MESSAGE_LOOP_H_
#define SANGAME_BASE_MESSAGE_LOOP_H_

#include "base/base_export.h"
#include "base/base.h"

namespace sangame {
namespace base {

struct CanvasMessage {
	Handle device_handle;
	Rect view_area;
	Rect clip_area;
};

struct KeyMessage {
	int	scan_code;
	int	repeat_count;
	int	flags;
};

struct MouseMessage {
	int	flags;
	Point cursor_coord;
	int	rotated_distance;
};

class BASE_EXPORT MessageLoop {
public:
    enum Type {
        MSG_CREATE,
		MSG_SETRECT,
		MSG_DRAW,
		MSG_LBUTTONDOWN,
		MSG_LBUTTONUP,
		MSG_LBUTTONDBLCLK,
		MSG_RBUTTONDOWN,
		MSG_RBUTTONUP,
		MSG_RBUTTONDBLCLK,
		MSG_MOUSEMOVE,
		MSG_MOUSEWHEEL,
		MSG_KEYDOWN,
		MSG_KEYUP,
		MSG_CHAR,
		MSG_ACTIVATE,
    };

    bool FilterMessage( int message_type, void* message_ptr );

protected:
	virtual bool OnCreate(Handle* message_ptr);
	virtual bool OnSetRect(Rect* message_ptr);
	virtual bool OnDraw(CanvasMessage* message_ptr);
	virtual bool OnLButtonDown(MouseMessage* message_ptr);
	virtual bool OnLButtonUp(MouseMessage* message_ptr);
	virtual bool OnLButtonDblClk(MouseMessage* message_ptr);
	virtual bool OnRButtonDown(MouseMessage* message_ptr);
	virtual bool OnRButtonUp(MouseMessage* message_ptr);
	virtual bool OnRButtonDblClk(MouseMessage* message_ptr);
	virtual bool OnMouseMove(MouseMessage* message_ptr);
	virtual bool OnMouseWheel(MouseMessage* message_ptr);
	virtual bool OnKeyDown(KeyMessage* message_ptr);
	virtual bool OnKeyUp(KeyMessage* message_ptr);
	virtual bool OnChar(KeyMessage* message_ptr);
	virtual bool OnActivate(bool* message_ptr);
	virtual bool OnMessage(int message_type, void* message_ptr);

};

} // namespace base
} // namespace sangame

#endif // SANGAME_BASE_MESSAGE_LOOP_H_